// pages/api/api.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  goEvent(){
    wx.navigateTo({
      url: '/pages/event/event?id=1002&name=cici',
    })
  },
  goIndex(){
      wx.switchTab({
        url: '/pages/index/index',//路径后不能带参数
      })
  },
  sendAjax(){

    // https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items?start=0&count=6&for_mobile=1&ck=sew4;
    wx.request({
      url: 'https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items',
      method:"get",
      data:{
        start:0,
        count:6,
        for_mobile:1,
        ck:"sew4"
      },
      success:res=>{
        console.log(res);
        wx.showToast({
          title: '请求成功',
          // icon:"success",
          image:"/images/success.png",
          duration:1500
        })
      },
      fail:error=>{
        wx.showToast({
          title: '请求失败',
          image:"/images/error.png"
        })
      }
    })
  },
  doModel(){
    wx.showModal({
        title:"提示",
        content:"确定要删除吗",
        success:function(res){
          if(res.confirm){
            console.log("点击了确定");
          }else{
            console.log("点击了取消");
          }
        }
    })
  },
  doStorage(){
    //同步添加数据
    wx.setStorageSync('user',{
      name:"alice",
      age:10,
      height:140
    });

    //读取缓存数据
    // var user=wx.getStorageSync('user')
    // console.log(user);

    //清除缓存数据,根据key清除指定缓存数据
    // wx.removeStorageSync('user');

    //清除所有缓存数据
    wx.clearStorageSync();
  }
})